require 'json'
require 'uuid' 

class GetNumUsersController < ApplicationController
	def index
			render :text=>"hi"              
	end
	
	def test
		render :text => "hi"
	end
	
	def get_current_workload	
		agent_id = params[:agent_id]		
		render :text => JSON.generate(platform_wokloads[:worload][1])
	end
	
	def register		
		plat_id = params[:platform_id]
		agent_id = params[:agent_id]
		Coordinator::Application.platform_agents << {plat_id => agent_id}
		json = JSON.generate("successfull")
		render :text => json
	end
	
	def get_workload 
		plat_id  = params[:platform_id] 
		workload = Coordinator::Application.platform_workloads[plat_id]
		json = JSON.generate({:workload=>workload})
		render :text => json
	end
	
	def create_platform
		plat_id = UUID.new
		workload = params[:workload].split.collect {|i| i.to_i}		
		 Coordinator::Application.platform_workloads[plat_id]=workload
		 render :text => JSON.generate({:platform_id=>plat_id})
	end
end
